<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
        .box{
            width: 800px;
            height: 800px;
        }
    </style>
  </head>
  <body>
    <div id="app">
        <!-- 动态style绑定写法一:字符串拼接 (不推荐)-->
        <div class="box" :style="`background:${isRed?'red':'green'}`"></div>
        <!-- 动态style绑定写法二:对象 (推荐)-->
        <div class="box" :style="{background:isRed?'red':'green'}"></div>
        <!-- 动态style绑定写法三:数组 (内部可以书写多个对象)-->
        <div class="box" :style="[{background:isRed?'red':'green'}]"></div>
        <div class="box" :style="[style1],[style2]"></div>
    
    </div>

    <script>
      Vue.config.productionTip = false;

      const vm = new Vue({
        el: "#app",
        data() {
          return{
            isRed:true,
            style1:{
                border:"1px solid #000",
            },
            style2:{
                color:"skyblue",
            },
        };
      },
    });
    </script>
  </body>
</html>
